function showWord() {
	def.innerHTML = currentWord.def;
	rForm.inputWord.value = "";
	cWord.innerHTML = "";
	mark.innerHTML = "";
	checked = false;
}

function checkWord() {
	var correctWord = currentWord.en;
	var inputWord = rForm.inputWord.value;
	if (inputWord !== correctWord) {
		mark.innerHTML = WRONG;
		Session.addToErrorList(Session.getIndex());
	} else {
		mark.innerHTML = RIGHT;
	};
	cWord.innerHTML = correctWord;
	checked = true;
	Session.updateCurrentWord();
}

window.onload = function() {
	window.RIGHT = '<font color="green">√</font>';
	window.WRONG = '<font color="red">×</font>';
	window.rForm = document.getElementById("recite-form");
	window.def = document.getElementById("def");
	window.mark = document.getElementById("mark");
	window.cWord = document.getElementById("correctWord");
	// global variables
	window.checked = false;
	window.currentWord = null;

	Session.reset();
	showWord();
	rForm.onsubmit = function() {
		if (checked || !rForm.inputWord.value) {
			showWord();
		} else {
			checkWord();
		}
		return false;
	}
}
